Skip to content

Conversation

@robbyzhaox
Copy link
Contributor

This commit refactors getContentFromChatResponse to use Java's Optional for null handling. Initially, the method relied on explicit null checks for ChatResponse and its nested properties.

By replacing these with Optional chaining, the code is more streamlined, following Java 8+ best practices for handling nulls. This improves readability and reduces clutter from traditional null - checking.

Now, Optional.ofNullable safely manages the ChatResponse object, and map operations traverse nested objects, gracefully returning null if any link in the chain is null.

@robbyzhaox robbyzhaox changed the title Refactor getContentFromChatResponse method to use Optional for null h… Refactor getContentFromChatResponse method to use Optional for null handling Dec 27, 2024
@ilayaperumalg ilayaperumalg self-assigned this Jan 17, 2025
@ilayaperumalg ilayaperumalg added this to the 1.0.0-M6 milestone Jan 17, 2025
@ilayaperumalg
Copy link
Member

@robbyzhaox Thanks for the clean up! Rebased and merged as 5783c5b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants